# src/rpc/CMakeLists.txt

# 获取当前源文件所在目录的绝对路径
get_filename_component(RPC_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)

# 包含所有.cc文件，但不包括.h文件
file(GLOB RPC_SRCS "${RPC_SRC_DIR}/*.cc")

# 创建RPC库
add_library(sola_rpc STATIC ${RPC_SRCS}) # 使用STATIC库

# 链接依赖
find_package(Protobuf REQUIRED)
find_package(Boost REQUIRED serialization)

target_link_libraries(sola_rpc
    PUBLIC
        sola_net
        ${Protobuf_LIBRARIES}
        ${Boost_LIBRARIES}
)

# 设置包含目录
target_include_directories(sola_rpc PUBLIC
    # ${CMAKE_SOURCE_DIR}/src/common/include # 通用头文件
    # ${CMAKE_SOURCE_DIR}/src/rpc/include    # RPC库自己的头文件
    # ${CMAKE_SOURCE_DIR}/.protobuf_generated/ # 如果pb文件生成在单独目录
    $<INSTALL_INTERFACE:include> # For installed version
    $<BUILD_INTERFACE:${RPC_SRC_DIR}> # For build tree version
)

# 安装规则 (可选，但推荐)
install(TARGETS sola_rpc DESTINATION lib)
install(DIRECTORY include/rpc DESTINATION include) # 假设你的include头文件在 src/rpc/include 下
